// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// V1Notification v1 notification
//
// swagger:model v1Notification
type V1Notification struct {

	// device Id
	DeviceID string `json:"deviceId,omitempty"`

	// lang
	Lang *V1Language `json:"lang,omitempty"`

	// message
	Message string `json:"message,omitempty"`

	// notification Id
	NotificationID string `json:"notificationId,omitempty"`

	// notification status
	NotificationStatus *ActDeviceApiv1Status `json:"notificationStatus,omitempty"`

	// username
	Username string `json:"username,omitempty"`
}

// Validate validates this v1 notification
func (m *V1Notification) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateLang(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateNotificationStatus(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *V1Notification) validateLang(formats strfmt.Registry) error {
	if swag.IsZero(m.Lang) { // not required
		return nil
	}

	if m.Lang != nil {
		if err := m.Lang.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("lang")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("lang")
			}
			return err
		}
	}

	return nil
}

func (m *V1Notification) validateNotificationStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.NotificationStatus) { // not required
		return nil
	}

	if m.NotificationStatus != nil {
		if err := m.NotificationStatus.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("notificationStatus")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("notificationStatus")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this v1 notification based on the context it is used
func (m *V1Notification) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateLang(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateNotificationStatus(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *V1Notification) contextValidateLang(ctx context.Context, formats strfmt.Registry) error {

	if m.Lang != nil {
		if err := m.Lang.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("lang")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("lang")
			}
			return err
		}
	}

	return nil
}

func (m *V1Notification) contextValidateNotificationStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.NotificationStatus != nil {
		if err := m.NotificationStatus.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("notificationStatus")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("notificationStatus")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *V1Notification) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *V1Notification) UnmarshalBinary(b []byte) error {
	var res V1Notification
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
